package com.fenqing.leetcode.code.t0_200.t100_200;

import com.fenqing.annotations.Execute;
import com.fenqing.core.Topic;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fenqing
 */
public class Topic119 extends Topic {
    /**
     * 构造器
     *
     * @param input 输入
     */
    public Topic119(String input) {
        super(input);
    }

    @Execute
    public List<Integer> getRow(int rowIndex) {
        int len = rowIndex + 1;
        List<Integer> result = new ArrayList<>();
        if (len == 0) {
            return result;
        }
        result.add(1);
        for (int i = 1; i < len; i++) {
            result.add(0);
            for (int j = i; j >= 1; j--) {
                result.set(j, result.get(j) + result.get(j - 1));
            }
        }
        return result;
    }

    public static void main(String[] args) {
        Topic119 topic119 = new Topic119("3");
        List<Integer> run = topic119.run();
        System.out.println(run);
    }

}
